<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace App\Service\Dao;

use App\Model\Shoufang;
use App\Model\Zufang;
use Han\Utils\Service;

class FangDao extends Service
{
    public function getList($type, $page, $limit)
    {
        $model = null;
        if ($type == 'zufang') {
            $model = new Zufang();
        } elseif ($type == 'shoufang') {
            $model = new Shoufang();
        }
        $list = $model::query()->orderByDesc('id')->offset($page - 1 * $limit)->limit($limit)->get();
        if ($list) {
            var_dump($list->toArray());
            return $list->toArray();
        }
        return false;
    }

    public function getDetail($id, $kind)
    {
        $model = null;
        if ($kind == 'zufang') {
            $model = new Zufang();
        } elseif ($kind == 'shoufang') {
            $model = new Shoufang();
        }
        $detail = $model::query()->where('id', $id)->first();
        if ($detail) {
            var_dump($detail->toArray());
            return $detail->toArray();
        }
        return false;
    }
}
